<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选项卡</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 500px;
            margin: 100px auto 0;
            background-color: #c2abab;
        }
        .title{
            display: flex;
            justify-content: space-around;
            height: 70px;
            font-size: 20px;
            color: black;
        }
        .title .but{
            width: 120px;
            margin-top: 12px;
            border-radius: 5px;
            cursor: pointer;
            text-align: center;
            line-height: 60px;
            background-color: #6262e7;
        }
        .box .content{
            height: 300px;
            margin: 15px 0 0;
            color: brown;
            font-size: 25px;
            text-align: center;
            line-height: 300px;
            font-family: sans-serif;
            background-color: #b65151;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="title">
            <div class="but red">红色</div>
            <div class="but blue">蓝色</div>
            <div class="but green">绿色</div>
        </div>
        <div class="content">

        </div>
    </div>
    <script>
        var redBut=document.querySelector(".red");
        var blueBut=document.querySelector(".blue");
        var greenBut=document.querySelector(".green");
        var content=document.querySelector(".content")
        redBut.onclick=function(){
            content.style.backgroundColor="#e10c0c";
            content.innerText="我是#e10c0c的红色";
        }
        blueBut.onclick=function(){
            content.style.backgroundColor="#5050ce";
            content.innerText="我是#5050ce蓝色";
        }
        greenBut.onclick=function(){
            content.style.backgroundColor="#5ee95e";
            content.innerText="我是#5ee95e绿色";
        }

    </script>



</body>
</html>